<template>
  <div class="hyh-video__list">
    <!-- 列表 -->
    <a href="#"
      class="item"
      v-for="item in list"
      @click.prevent="gotoVideoDetail(item)"
    >
      <div class="item-top">
        <!-- 是否移除 -->
        <i
          class="icon-move"
          v-if="parentName === 'mycollection'"
          @click.stop="moveVideo(item.collectionId)"
        >
          <hyh-icon
            href="icon-guanbi-xuanfu"
            size="12px"
            style="margin:-2px 2px 0 0"
          ></hyh-icon
          >移除
        </i>
        <!-- 状态 -->
        <i v-else-if="parentName === 'liveVideo'" class="icon-living">直播中</i>
        <!-- 图 -->
        <img :src="item.coverPath" @error="imgUrlError" />
      </div>
      <!-- 信息 -->
      <div class="item-bottom">
        <div class="item-tit">
          <i class="icon-tit" v-if="item.subjectName">{{
            item.subjectName.substr(0, 1)
          }}</i>
          {{ item.videoName }}
        </div>
        <div class="item-info">
          {{ item.teacherName }}（{{ item.orgName }}）
        </div>
      </div>
    </a>
  </div>
</template>
<script>
/**
 * 视频列表组件-用于点播直播有封面图的列表
 */

export default {
  name: 'video-list',
  props: {
    // 父组件名字
    parentName: {
      type: String,
      default: ''
    },
    // 列表
    list: {
      required: true,
      type: Array,
      default: () => []
    }
  },
  data() {
    return {};
  },
  methods: {
    // 跳转到详情页 item {Object} 视频信息
    gotoVideoDetail(item) {
      this.$emit('gotoVideoDetail', item);
    },
    // 移除视频
    moveVideo(collectionId) {
      this.$emit('moveVideo', collectionId);
    },
    // 图片地址出错
    imgUrlError(e) {
      // e.target.src = require('../../../assets/images/imgUrlError.png');
    }
  },
  mounted() {
    this.$nextTick(() => { });
  }
};
</script>
<style lang="scss">
  .hyh-video__list {
    .item {
      display: inline-block;
      width: 268px;
      margin-right: 24px;
      margin-bottom: 24px;
      border-radius: 5px;
      border: 1px solid rgba(236, 236, 236, 1);
      box-shadow: 0px 4px 13px 0px rgba(224, 224, 224, 0.6);
      overflow: hidden;
      &:nth-child(4n) {
        margin-right: 0;
      }
      &:hover .item-top .icon-move {
        display: inline-block;
      }
      .item-top {
        width: inherit;
        height: 160px;
        position: relative;
        img {
          width: 100%;
          height: 160px;
        }
        .icon-living {
          position: absolute;
          top: 4px;
          right: 4px;
          display: inline-block;
          width: 42px;
          height: 16px;
          border-radius: 3px;
          font-size: 10px;
          text-align: center;
          background-color: #dfb371;
          color: #ffffff;
          font-style: normal;
        }
        .icon-move {
          position: absolute;
          top: 4px;
          right: 4px;
          display: none;
          width: 50px;
          height: 20px;
          line-height: 20px;
          border-radius: 3px;
          font-size: 12px;
          text-align: center;
          background-color: #000000;
          color: #ffffff;
          font-style: normal;
          opacity: 0.5;
        }
      }
      .item-bottom {
        width: inherit;
        height: 62px;
        .icon-tit {
          display: inline-block;
          width: 16px;
          height: 16px;
          margin-right: 5px;
          border-radius: 2px;
          border: 1px solid #edcba5;
          font-size: 12px;
          text-align: center;
          color: #b3732d;
          font-style: normal;
        }
        .item-tit {
          color: #333333;
          font-size: 16px;
          margin: 13px 16px 8px 16px;
        }
        .item-info {
          font-size: 12px;
          color: #999999;
          margin: 0 16px;
        }
        .item-tit,
        .item-info {
          overflow: hidden;
          text-overflow: ellipsis;
          white-space: nowrap;
        }
      }
    }
  }
</style>


